package com.yjq.yys.yhCalculate.utils;

import java.io.*;

public class ReadJson {

	public static String readJson(InputStream inputStream) {

		BufferedReader reader = null;
		StringBuffer lastStr = new StringBuffer();

		try {

			InputStreamReader inputStreamReader = new InputStreamReader(inputStream,"UTF-8");

			reader = new BufferedReader(inputStreamReader);

			String tempString = null;
			while ((tempString = reader.readLine()) != null) {
				lastStr.append(tempString);
			}
			reader.close();

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		return lastStr.toString();
	}

	/*public static List<Yh> jsonToList(String jsonStr,int userId) {
		List<Yh> yhList = new ArrayList<>();

		JSONArray jsonArray = JSONArray.fromObject(jsonStr);

		List<Map<String,Object>> mapListJson = (List)jsonArray;

		for (int i = 0; i < 1; i++) {
			Map<String,Object> obj=mapListJson.get(i);
			for(Map.Entry<String,Object> entry : obj.entrySet()){
				String strkey1 = entry.getKey();
				Object strval1 = entry.getValue();
				System.out.println("KEY:"+strkey1+"  -->  Value:"+strval1+"\n");
			}
		}

		return yhList;
	}*/
}